package main

import "fmt"

func main() {
	arr := make([]interface{}, 3)

	arr[0] = 1
	arr[1] = "mike"
	arr[2] = 3.14
	//fmt.Println(arr)

	for i, v := range arr {
		data, ok := v.(int)
		if ok {
			fmt.Println(data, "是整型数据")
		}

		if data, ok := v.(int); ok == true {
			fmt.Println(data, "是int数据")
		}

		data1, ok1 := v.(string)
		if ok1 {
			fmt.Println(data1)
		}

		switch value := v.(type) {
		case int:
			fmt.Printf("arr[%d]是int类型,值为%d\n", i, value)
		case float32:
			fmt.Printf("arr[%d]是float32类型,值为%v\n", i, value)
		case float64:
			fmt.Printf("arr[%d]是float64类型,值为%v\n", i, value)
		case string:
			fmt.Printf("arr[%d]是string类型，值为%s\n", i, value)
		}
	}

}
